package com.starinside.wp.controller;



import com.starinside.wp.domain.ChildActivity;
import com.starinside.wp.domain.WxUser;
import com.starinside.wp.foundation.model.ErrorCode;
import com.starinside.wp.foundation.model.StatusResponse;
import com.starinside.wp.foundation.vo.ChildActivityVo;
import com.starinside.wp.service.ChildActivityService;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.Map;



/**
 * (ChildActivity)表控制层
 *
 * @author makejava
 * @since 2025-02-21 15:04:17
 */
@RestController
@RequestMapping("childActivity")
public class ChildActivityController {
    @Autowired
    ChildActivityService childActivityService;


    @ApiOperation(value = "活动列表",httpMethod = "POST")
    @RequestMapping(value = "/activeList", method = RequestMethod.POST)
    public StatusResponse activeList(HttpServletRequest req,String childId) {
        WxUser user = (WxUser) req.getSession().getAttribute("loginUser");
//        if(StringUtils.isEmpty(user.getParentId()) || StringUtils.isEmpty(user.getDefaultBabyId()) || StringUtils.isEmpty(user.getParentMobile())){
//            return StatusResponse.error(ErrorCode.CHILDREN_NOT_EXIST,"当前账号下没有宝宝信息");
//        }
        List<ChildActivityVo> list=childActivityService.activeList(childId);

        return StatusResponse.success(list);
    }

    @ApiOperation(value = "活动详情",httpMethod = "POST")
    @RequestMapping("/detail")
    @ResponseBody
    public StatusResponse detail( String activeId,String childId) {
        ChildActivityVo detailByActiveId = childActivityService.getDetailByActiveId(activeId,childId);

        return StatusResponse.success(detailByActiveId);
    }


}

